<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "migration_package".
 *
 * @property int $id
 * @property string $original_package_id
 * @property string $new_package_id
 */
class MigrationPackage extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'migration_package';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['original_package_id', 'new_package_id'], 'required'],
            [['original_package_id', 'new_package_id'], 'integer'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'original_package_id' => 'Original Package ID',
            'new_package_id' => 'New Package ID',
        ];
    }

    /**
     * @inheritdoc
     * @return MigrationPackageQuery the active query used by this AR class.
     */
    public static function find()
    {
        return new MigrationPackageQuery(get_called_class());
    }

    public static function getPackageId($original_package_id)
    {
        return MigrationPackage::find()->where("original_package_id=$original_package_id")->one()->new_package_id;
    }
}
